﻿using System;
using System.Collections;
using System.Collections.Generic;
namespace hashtable_test {
    class Program {
        static void Main (string[] args) {
            Console.WriteLine ("Hello World!");

            LinkList<int> mylinklist = new LinkList<int> ();
            mylinklist.AddNode (new Node<int> (10));
            mylinklist.AddNode (new Node<int> (7));
            mylinklist.AddNode (new Node<int> (6));
            mylinklist.AddNode (new Node<int> (8));

            mylinklist.AddNode (new Node<int> (13));
            mylinklist.AddNode (new Node<int> (12));
            mylinklist.AddNode (new Node<int> (14));

            Console.WriteLine ("完成");
        }

        public class Node<T> {
            public Node<T> next;
            public T Data;
            public Node (T data) {
                next = null;
                Data = data;
            }
            public Node () {
                next = null;
                Data = default (T);
            }
        }
        public class LinkList<T> {
            public Node<T> head;

            public LinkList () {
                head = new Node<T> ();

                head.next = null;
                head.Data = default (T);
            }
            public LinkList (Node<T> node, T data) {
                if (head == null) {
                    head = new Node<T> ();
                    head.next = null;
                    head.Data = data;
                } else {
                    head.next = node;
                }
            }
            /// <summary>
            /// 尾插法实现结点的插入
            /// </summary>
            /// <param name="node"></param>
            public void AddNode (Node<T> node) {
                if (head == null) {
                    head = node;
                    head.next = null;
                    head.Data = node.Data;
                }
                var temp = head;
                while (temp.next != null) {
                    temp = temp.next;
                }
                temp.next = node;
                temp.next.Data = node.Data;
            }
        }
    }
}